<?php
use yii\widgets\ActiveForm;
?>
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../static/jBox/Skins/Metro/jbox.css" type="text/css">
<link rel="stylesheet" href="../static/dist/css/AdminLTE.min.css" type="text/css">
<link rel="stylesheet" href="../static/css/admin.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/treeTable/jquery.treetable.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/treeTable/jquery.treetable.theme.default.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datatables/jquery.dataTables.css" type="text/css">
<style>
    .ul_tree_display{
        display: none;
    }
    .tr_tree_display{
        display: none;
    }
    .table>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
    }
    .layui-layer-content p{
        padding: 15px;
    }
    .dataTables_length{
        margin-top: 10px;
    }
    /* 调整模态框让富文本正常显示 */
    .modalBox{
      /*  bottom: auto !important;*/
        margin: 0 auto !important;
    }
    .modalBox .modal-dialog{
        margin-top: 10px !important;
    }
    .modalBox .form-group{
        margin-bottom:10px !important;
    }
    .modalBox .modal-header{
        padding: 10px 15px !important;
    }
    .modalBox .form-group .form-control{
      /*  height: 30px !important;
        padding: 0 12px !important;*/
    }
    .modalBox button{
        height: 30px;
        line-height: 1!important;
    }
    .modalBox .col-md-12{
        margin-left: -30px !important;
    }
</style>
<div class="tabs-panel">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <button type="button" class="btn btn-success depart-modal category-show-btn" style="width: 100px;">添加分类</button>
                    <!--<h3 class="box-title">Hover Data Table</h3>-->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table id="example2" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="">分类名称</th>
                            <th class="">排序</th>
                            <th class="">图片</th>
                            <th class="">内容</th>
                            <th class=""><?=TITLE_STATUS?></th>
                            <th class="">修改</th>
                            <th class="">添加子分类</th>
                            <th class="" style="text-align: center;">删除</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if(!empty($list)){?>
                            <?php foreach ($list as $key => $val) {?>
                                <tr data-tt-id="<?= $val['id']?>" data-tt-parent-id="<?= $val['parent_id']?>" class="">
                                    <td class="" style="width: 300px;padding-left: 20px;">
                                        <?= $val['html']?>
                                        <?= $val['category_name']?>
                                    </td>
                                    <td class="" style="width: 100px;"><?= $val['sort']?></td>
                                    <td class="" style="width: 100px;">
                                        <a href="javascript:;" onclick="showMoreImg('<?=$val['img_url']?>')">查看<?=($val['parent_id'] == '0' ? '小图' : '品类小图')?></a>
                                    </td>
                                    <td class="" style="width: 100px;">
                                        <a href="javascript:;" onclick="showContent(<?= $val['id']?>)">查看内容</a>
                                        <div style="display: none;" class="show_content_<?= $val['id']?>">
                                            <?=$val['content']?>
                                        </div>
                                    </td>
                                    <td class="" style="width: 100px;">
                                        <span class="switch" data-id="<?= $val['id']?>" data-flg="<?=($val['use_flg'] == 1 ? 0 : 1)?>"><input  style="width:20px;height:20px;"  type="checkbox" <?=($val['use_flg'] == 1 ? 'checked="checked"' : '')?> class="input-check"></span>
                                    </td>
                                    <td class="" style="width: 100px;"><a href="javascript:;" onclick="updateCategory(<?= $val['id']?>)">修改</a></td>
                                    <td class="" style="width: 100px;"><a href="javascript:;" onclick="addCategory(<?= $val['id']?>)">添加</a></td>
                                    <td class="" style="width: 50px;text-align: center;"><a href="javascript:;" onclick="delCategory(<?= $val['id']?>)">X</td>
                                </tr>
                            <?php } ?>
                        <?php }else{?>
                            <tr><td colspan="10" style="text-align: center">暂无分类！</td></tr>
                        <?php }?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>

    <div class="modal fade modalBox" id="add-category"  aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width:70%">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加分类
                    </h4>
                </div>
                <div class="modal-body">
                    <form action="/goods-category/add-category" method="post" id="category_form">
                        <div class="box-body">
                            <div class="col-md-12">
                            <div class="form-group col-md-6">
                                <label for="exampleInputPassword1">上级分类</label>
                                <select name="parent_id" id="parent_id_other" class="form-control" style="width:50%;">
                                    <option value="0">一级分类</option>
                                    <?php if(!empty($list)){?>
                                        <?php foreach($list as $value){?>
                                            <option value="<?= $value['id']?>"><?= $value['html']?><?= $value['category_name']?></option>
                                        <?php }?>
                                    <?php } ?>
                                </select>
                            </div>

                            <div class="form-group col-md-6">
                                <label for="exampleInputPassword1"><span class="text-danger">* </span>分类名称</label>
                                <input type="text" name="category_name" class="form-control" style="width:50%;" id="category_name" placeholder="分类名称">
                            </div>
                            </div>
                            <div class="form-group">
                            	<label for="exampleInputPassword1">上传品类小图</label>
                                <button type="button" class="btn btn-success depart-modal upload-img-btn" style="width: 100px;">上传图片</button>
                                <button style="display: none;width: 100px;" data-img="" type="button" class="btn btn-success depart-modal show-img-btn">查看图片</button>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">图片链接</label>
                                <input type="text" name="img_link" style="width:50%;" class="form-control" placeholder="图片链接">
                                <input type="hidden" name="img_url" class="form-control" id="img_url">
                            </div>
                               <div class="col-md-12">
                            <div class="form-group col-md-6">
                                <label for="exampleInputPassword1">排序</label>
                                <input type="text" style="width: 50%;" name="sort" class="form-control" placeholder="排序">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="exampleInputEmail1"><span class="text-danger">* </span>状态</label>
                                <select name="use_flg" class="form-control" style="width: 50%;">
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>
                               </div>
                            <div class="div">
                                <label for="exampleInputPassword1">分类文字描述</label>
                                <!--<script id="content" type="text/plain"></script>-->
<!--                                 <textarea class="form-control ckeditor" name="content" id="content" placeholder="" ></textarea> -->
								<textarea class="form-control xheditor" name="content" id="content" placeholder=""  style="width: 100%;"></textarea>
                            </div>

                        </div>
                        <!-- /.box-body -->

                    </form>
                    <div style="display: none">
                        <?php $form = ActiveForm::begin(['id'=>'upload_form','action'=>'/common/img-upload'],['options' => ['enctype' => 'multipart/form-data']]) ?>
                        <?= $form->field($model, 'img_url')->fileInput(['class' => 'upload_file']) ?>
                        <?php ActiveForm::end() ?>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_category">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="modal fade modalBox" id="update-category" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width:70%">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        修改分类
                    </h4>
                </div>
                <div class="modal-body">
                    <form action="/goods-category/update-category" method="post" id="update_form">
                        <div class="box-body">
                        	<div class="col-md-12">
                        		<div class="form-group col-md-6">
                                    <label for="exampleInputPassword1">上级分类</label>
                                    <select id="parent_id" name="parent_id" class="form-control" style="width: 50%;" disabled>
                                        <option value="0">一级分类</option>
                                        <?php if(!empty($list)){?>
                                            <?php foreach($list as $value){?>
                                                <option value="<?= $value['id']?>"><?= $value['html']?><?= $value['category_name']?></option>
                                            <?php }?>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="form-group col-md-6">
                                    <label for="exampleInputPassword1">分类名称</label>
                                    <input type="text" name="category_name" class="form-control" style="width: 50%;" id="category_name_ot" placeholder="分类名称">
                                </div>
                        	</div>
                            <div class="form-group">
                            	<label for="exampleInputPassword1">上传品类小图</label>
                                <button type="button" class="btn btn-success depart-modal upload-img-btn-ot" style="width: 100px;">上传图片</button>
                                <button style="display: none;width: 100px;" data-img="" type="button" class="btn btn-success depart-modal show-img-btn-ot">查看图片</button>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">图片链接</label>
                                <input type="text" name="img_link" class="form-control" style="width: 50%;" id="img_link" placeholder="图片链接">
                                <input type="hidden" name="img_url" class="form-control" id="img_url_ot">
                                <input type="hidden" name="id" class="form-control" id="id">
                            </div>

							<div class="col-md-12">
    							<div class="form-group col-md-6">
                                    <label for="exampleInputPassword1">排序</label>
                                    <input type="text" style="width: 50%;" name="sort" class="form-control" id="sort" placeholder="排序">
                                </div>
    
                                <div class="form-group col-md-6">
                                    <label for="exampleInputEmail1">状态</label>
                                    <select id="use_flg" name="use_flg" class="form-control" style="width: 50%;">
                                        <option value="1">启用</option>
                                        <option value="0">禁用</option>
                                    </select>
                                </div>
							</div>
                            

                            <div class="form-group">
                                <label for="exampleInputPassword1">分类文字描述</label>
                                <textarea class="form-control xheditor" name="content" id="content_other" placeholder="" style="width: 100%;"></textarea>
                            </div>

                        </div>
                        <!-- /.box-body -->

                    </form>
                    <div style="display: none">
                        <?php $form = ActiveForm::begin(['id'=>'upload_form_update','action'=>'/common/img-upload'],['options' => ['enctype' => 'multipart/form-data']]) ?>
                        <?= $form->field($model, 'img_url')->fileInput(['class' => 'upload_file_ot']) ?>
                        <?php ActiveForm::end() ?>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_category_update">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

<div class="modal fade" id="content-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    分类文字描述
                </h4>
            </div>
            <div class="modal-body">
                <form action="/goods-category/update-recommend" method="post" id="update_recommend_form">
                    <div class="form-group">
                        <label for="exampleInputPassword1">分类文字描述</label>
<!--                         <textarea class="form-control ckeditor" name="show_category_content" id="show_category_content" placeholder="" ></textarea> -->
						<textarea class="form-control xheditor" name="show_category_content" id="show_category_content" placeholder=""  style="width: 100%;"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<?php include ('../views/seo/seo-modal.php');?>
<input id="img_type" type="hidden"/>
<input type="hidden" value="<?php echo Yii::$app->params['imageBathUrl'] . '/' ?>" id="imageBathUrl"/>
<!-- 固定js -->
<script type="text/javascript" src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../static/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="../static/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<script type="text/javascript" src="../static/plugins/treeTable/jquery.treetable.js"></script>
<!-- 图片上传插件 -->
<script type="text/javascript" src="../static/plugins/jquery.form.js"></script>
<!-- 图片显示插件 -->
<script type="text/javascript" src="../static/plugins/layer/layer.js"></script>
<!-- 富文本框插件 -->
<script type="text/javascript" src="/static/plugins/xheditor/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="/static/plugins/xheditor/xheditor_lang/zh-cn.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="../static/app/global.js?version=<?=Yii::$app->params['version']?>"></script>
<script type="text/javascript" src="/static/app/goods-category/list.js?version=<?=Yii::$app->params['version']?>"></script>